#!/bin/bash

outputdir="./"
while getopts "o:i:" flag
do
  if [ "$flag" = o ]; then
    outputdir=$OPTARG
  fi
  if [ "$flag" = i ]; then
    inputfile=$OPTARG
  fi
done
if [ $outputdir ] && [ $inputfile ]; then
    mkdir $outputdir
    for domain in epirus-dom1-10 delidia-dom1-11 andaluza-dom1-12 africander-dom1-13 epirus-dom2-14 delidia-dom2-15 andaluza-dom2-16 africander-dom2-17
    do
      echo $domain
      head -n 1 $inputfile > $outputdir/$domain.log
      grep "$domain.*running" $inputfile >> $outputdir/$domain.log
    done

fi
